﻿<UserControl x:Class="ForumsBrowser.UserHeader"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:fb="clr-namespace:ForumsBrowser"
    xmlns:library="clr-namespace:ForumsBrowser.BusinessObjects;assembly=ForumsBrowser.BusinessObjects"
     x:Name="userHeader">
    <Grid x:Name="grid">
            <Grid Margin="4,4,2,2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="65"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Border BorderThickness="2" Grid.Column="0" BorderBrush="White" Width="60" Height="60" HorizontalAlignment="Left" CornerRadius="5,5,5,5" Padding="2">
                    <Image HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Source="{Binding ElementName=userHeader, Path=User.Image, Converter={StaticResource ImageConverter} }"/>
                </Border>
                <StackPanel Orientation="Vertical" Grid.Column="1" Margin="2,2,2,2">
                    <TextBlock Text="{ Binding ElementName=userHeader, Path=User.DisplayName }" FontSize="14" FontWeight="Bold"/>
                    <TextBlock Margin="0,2,0,0" FontSize="12" >
                        <TextBlock.Text>
                            <MultiBinding StringFormat="{}Points: {0}  Posts: {1}  Answers: {2}  Ratio {3:F2}%">
                                <Binding ElementName="userHeader" Path="User.Points" />
                                <Binding ElementName="userHeader"  Path="User.Posts"/>
                                <Binding ElementName="userHeader"  Path="User.Answers" />
                                <Binding ElementName="userHeader"  Path="User.Ratio" />                                
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                    <StackPanel Orientation="Horizontal" Margin="0,2,0,0">
                        <TextBlock FontSize="12" Text="Microsoft Employee   " Visibility="{Binding ElementName=userHeader, Path=User.Microsoft, Converter={StaticResource BoolVis} }"/>
                        <TextBlock FontSize="12" Text="Most Valuable Professional   " Visibility="{Binding ElementName=userHeader, Path=User.MVP, Converter={StaticResource BoolVis} }"/>
                        <TextBlock FontSize="12" Text="Microsoft Partner   " Visibility="{Binding ElementName=userHeader, Path=User.Partner, Converter={StaticResource BoolVis} }"/>
                    </StackPanel>
                    <fb:MedalControl HorizontalAlignment="Left" Margin="0,2,0,0" 
                                     Achieved="{Binding ElementName=userHeader, Path=User.Stars, Mode=OneWay}" Edge="White"  
                                     FillBrush="Yellow" Height="16"  />
                </StackPanel>
            </Grid>
    </Grid>
</UserControl>
